#include <stdio.h>  
#include <mysql/mysql.h>  
#include <string.h>  
void show(MYSQL *mysql){  
	printf("        查询学生表数据        \n"); 
	MYSQL_RES  *res = NULL;  
	MYSQL_ROW   row;  
	char *query_str = NULL;  
	int  rc, i, fields;  
	int   rows;  
	query_str = "select * from student";  
	rc = mysql_real_query(mysql, query_str, strlen(query_str));  
	if (0 != rc)
	{  
		printf("mysql_real_query(): %s\n", mysql_error(mysql));  
	}  
	res = mysql_store_result(mysql);  
	if (NULL == res)
	{  
		printf("mysql_restore_result(): %s\n", mysql_error(mysql));  
	}  
	rows = mysql_num_rows(res);  
	printf("学生表一共有%d列\n", rows);  
	fields = mysql_num_fields(res);  
	printf("学生表一共有%d行\n", fields); 
	printf("学号\t姓名\t年龄\n");
	while ((row = mysql_fetch_row(res)))
	{  
		for (i = 0; i < fields; i++)
{  
			printf("%s\t", row[i]);  
		}  
		printf("\n");  
	}  
}  

